const browerTargets = !process.env.BROWSER_TARGET
  ? {
      // 默认只兼容chrome64
      chrome: '64',
    }
  : {
      chrome: '64',
      ie: '11',
    };

const config = {
  presets: [
    [
      '@babel/preset-env',
      {
        corejs: { version: '3', proposals: true },
        useBuiltIns: 'usage',
        targets: browerTargets,
      },
    ],
    '@babel/preset-typescript',
    '@babel/preset-react',
  ],
  plugins: [
    ['@babel/plugin-transform-runtime'],
    ['@babel/plugin-proposal-decorators', { legacy: true }],
    ['@babel/proposal-class-properties', { loose: true }],
    ['@babel/plugin-proposal-private-methods', { loose: true }],
    ['@babel/plugin-proposal-private-property-in-object', { loose: true }],
  ],
};

module.exports = config;
